package bishi.day32_5_31;

import java.util.*;

/**
 * 淘宝网店
 * @author 是阿秋啊
 * @date 2022/05/31 12:28
 **/

public class tao_bao {
    static Set<Integer> isPrime = new HashSet<Integer>() {{
        add(2);
        add(3);
        add(5);
        add(7);
        add(11);
    }};
    static Map<Integer, Integer> moneys = new HashMap<Integer, Integer>() {{
        put(1, 0);
        put(2, 62);
        put(3, 90);
        put(4, 121);
        put(5, 181);
        put(6, 212);
        put(7, 272);
        put(8, 303);
        put(9, 365);
        put(10, 425);
        put(11, 487);
        put(12, 517);
    }};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int year1 = sc.nextInt();
            int mon1 = sc.nextInt();
            int day1 = sc.nextInt();
            int year2 = sc.nextInt();
            int mon2 = sc.nextInt();
            int day2 = sc.nextInt();
            int sum = 0;
            for (int y = year1; y <= year2; y++) {
                if (y == year1 && y == year2) {
                    if (mon1 == mon2) {
                        if (isPrime.contains(mon1)) {
                            sum = day2 - day1 + 1;
                        } else {
                            sum = (day2 - day1 + 1) * 2;
                        }
                    } else {
                        if (mon1 > 2) {
                            if (isPrime.contains(mon1) && isPrime.contains(mon2)) {
                                sum = moneys.get(mon2) + day2 - moneys.get(mon1) - day1 + 1;
                            } else if (isPrime.contains(mon1)) {
                                sum = moneys.get(mon2) + day2 * 2 - moneys.get(mon1) - day1 + 1;
                            } else if (isPrime.contains(mon2)) {
                                sum = moneys.get(mon2) + day2 - moneys.get(mon1) - day1 * 2 + 2;
                            } else {
                                sum = moneys.get(mon2) - moneys.get(mon1) + (day2 - day1 + 1) * 2;
                            }
                        } else {
                            if (mon2 <= 2) {
                                sum = moneys.get(mon2) + day2 - moneys.get(mon1) - (day1 - 1) * 2;
                            } else {
                                if (isRun(year1)) {
                                    if (mon1 == 1) {
                                        sum = moneys.get(mon2) + day2 + 1 - moneys.get(mon1) - (day1 - 1) * 2;
                                    } else {
                                        sum = moneys.get(mon2) + day2 + 1 - moneys.get(mon1) - day1 - 1;
                                    }
                                } else {
                                    if (mon1 == 1) {
                                        sum = moneys.get(mon2) + day2 - moneys.get(mon1) - (day1 - 1) * 2;
                                    } else {
                                        sum = moneys.get(mon2) + day2 - moneys.get(mon1) - day1 - 1;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if (y == year1) {
                        if (mon1 > 2) {
                            if (isPrime.contains(mon1)) {
                                sum += moneys.get(12) + 62 - moneys.get(mon1) - day1 + 1;
                            } else {
                                sum += moneys.get(12) + 62 - moneys.get(mon1) - day1 * 2 + 2;
                            }
                        } else {
                            if (isRun(y)) {
                                if (isPrime.contains(mon1)) {
                                    sum += moneys.get(12) + 1 + 62 - moneys.get(mon1) - day1 + 1;
                                } else {
                                    sum += moneys.get(12) + 1 + 62 - moneys.get(mon1) - day1 * 2 + 2;
                                }
                            } else {
                                if (isPrime.contains(mon1)) {
                                    sum += moneys.get(12) + 62 - moneys.get(mon1) - day1 + 1;
                                } else {
                                    sum += moneys.get(12) + 62 - moneys.get(mon1) - day1 * 2 + 2;
                                }
                            }
                        }
                    }
                    if (y == year2) {
                        if (mon2 < 2) {
                            sum += day2 * 2;
                        } else if (mon2 == 2) {
                            sum += moneys.get(2) + day2;
                        } else {
                            if (isRun(y)) {
                                if (isPrime.contains(mon2)) {
                                    sum += moneys.get(mon2) + 1 + day2;
                                } else {
                                    sum += moneys.get(mon2) + 1 + day2 * 2;
                                }
                            } else {
                                if (isPrime.contains(mon2)) {
                                    sum += moneys.get(mon2) + day2;
                                } else {
                                    sum += moneys.get(mon2) + day2 * 2;
                                }
                            }
                        }
                    }
                    if (y != year1 && y != year2) {
                        if (isRun(y)) {
                            sum += moneys.get(12) + 63;
                        } else {
                            sum += moneys.get(12) + 62;
                        }
                    }
                }
            }
            System.out.println(sum);
        }
    }

    public static boolean isRun(int n) {
        if ((n % 4 == 0 && n % 100 != 0) || n % 400 == 0) {
            return true;
        }
        return false;
    }
}